﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using PetroFexService.FuelSupplyServiceReference;

namespace NSPetroFexService
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
    [ServiceContract]
    public interface IPetroFexService
    {
        //POS Operations
        [OperationContract]
        bool ConnectPOS(string POSId);
        [OperationContract]
        bool DisconnectPOS(string POSId);

        //Pump operations
        [OperationContract]
        bool ConnectPump(string pumpId);
        [OperationContract]
        bool DisconnectPump(string pumpId);

        //Manager System Operations
        [OperationContract]
        bool ConnectManagerSystem();
        [OperationContract]
        bool DisconnectManagerSystem();

        //Pump updaters
        [OperationContract]
        bool UpdatePump(string pumpId, float litresPumped, float thisSale);
        [OperationContract]
        List<PetrolPump> getPumps();
        [OperationContract]
        PetrolPump getPump(string pumpId);
        [OperationContract]
        void ActivatePump(string pumpId);
        [OperationContract]
        void DeactivatePump(string pumpId);

        //Customer Operations
        [OperationContract]
        bool MakeCustomerUnready(string pumpId);
        [OperationContract]
        bool MakeCustomerReady(string pumpId, string fuel);

        /* SQLite DB Operations */
        [OperationContract]//So POS Systems can log purchases to the database
        void LogCustomerPetrolPurchase(string fuel, float amount, float price);
        [OperationContract]
        List<float> GetPetrolTankLevels();

        [OperationContract]
        List<float> GetFuelPrices();
        [OperationContract]
        void SetFuelPrices(float unleadedPrice, float dieselPrice);

        [OperationContract]
        List<float> GetFuelSales(string date, string fuel);

    }

    // Use a data contract as illustrated in the sample below to add composite types to service operations
    [DataContract]
    public class PetrolPump
    {
        private string m_PumpId;
        private float m_LitresPumped, m_ThisSale;
        private bool pumpActive, customerReady;
        private string m_FuelType;

        [DataMember]
        public string PumpId
        {
            get { return m_PumpId; }
            set { m_PumpId = value; }
        }
        [DataMember]
        public float ThisSale
        {
            get { return m_ThisSale; }
            set { m_ThisSale = value; }
        }
        [DataMember]
        public float LitresPumped
        {
            get { return m_LitresPumped; }
            set { m_LitresPumped = value; }
        }
        [DataMember]
        public bool PumpActive
        {
            get { return pumpActive; }
            set { pumpActive = value; }
        }
        [DataMember]
        public bool CustomerReady
        {
            get { return customerReady; }
            set { customerReady = value; }
        }
        [DataMember]
        public string CurrentFuelType
        {
            get { return m_FuelType; }
            set { m_FuelType = value; }
        }
        
        public PetrolPump()
        {
            this.PumpId = "";
            this.ThisSale = 0.0f;
            this.LitresPumped = 0.0f;
            this.PumpActive = false;
            this.CustomerReady = false;
            this.CurrentFuelType = "None";
        }

        public PetrolPump(string pumpId)
        {
            this.PumpId = pumpId;
            this.ThisSale = 0.0f;
            this.LitresPumped = 0.0f;
            this.PumpActive = false;
            this.CustomerReady = false;
            this.CurrentFuelType = "None";
        }
    }
}
